<?php
namespace system\components;

/**
 * {@link Component} that holds only their name and value
 *
 *      <code>
 *          <name>
 *              value
 *          </name>
 *      </code>
 *
 * @see Component
 * @package system/components
 * @author Pavel Egorov {@link mailto:pavel@egorov.ru pavel@egorov.ru}
 * @version 0.0.1 * $Revision$
 * @copyright Copyright (c) 2011, Pavel Egorov
 */
class ValueComponent implements Component{
    private $name;
    private $value;

    /**
     * Constructor
     * 
     * @param String $strValue
     */
    public function  __construct($strName, $strValue) {
        $this->name = $strName;
        $this->value = $strValue;
    }

    /**
     * Creates DOMNode element
     * ex:
     *      <code>
     *          <name>
     *              value
     *          </name>
     *      </code>
     * @param DOMDocument $doc instance of DOMDocument
     * @return DOMNode part of xml document
     */
    public function toXML(DOMDocument $doc){
        return  $doc->createElement($this->name)->appendChild($doc->createTextNode($this->value));
    }
}

